/**
 * @author 黄波
 * 创建日期：2011Oct 10, 2011
 * TODO// N/A
 */
package com.platform.res.action;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Properties;

import org.apache.struts2.ServletActionContext;
import org.hibernate.cfg.Environment;

/**
 * 加载资源配置文件信息
 */
public class LoadResProfileAction extends ResourceSupport {

	private List<String> keys = new ArrayList<String>();
	private List<String> values = new ArrayList<String>();
	public List<String> getKeys() {
		return keys;
	}
	public void setKeys(List<String> keys) {
		this.keys = keys;
	}
	public List<String> getValues() {
		return values;
	}
	public void setValues(List<String> values) {
		this.values = values;
	}
	@Override
	public String execute() throws Exception {
		//加载系统配置文件
		String systemProfile = "/system.properties";
		InputStream stream = new FileInputStream(new File(ServletActionContext.getServletContext().getRealPath("/") + systemProfile));
		Properties properties = new Properties();
		properties.load(stream);
		stream.close();
		Enumeration enumKeys = properties.keys();
		while(enumKeys.hasMoreElements()) {
			keys.add(enumKeys.nextElement().toString());
		}
		Enumeration enumValues = properties.elements();
		while(enumValues.hasMoreElements()) {
			values.add(enumValues.nextElement().toString());
		}
		return SUCCESS;
	}

	
}
